
layui.use('laydate',function(){
	
	  var laydate = layui.laydate;
	   
	  var startTime =   laydate.render({
	      elem: '#startTime',
	      done: function(value, date){
	    	  endTime.config.min={    	    		
	      	    	year:date.year,
	      	    	month:date.month-1,//关键
	                  date:date.date,
	                  hours:date.hours,
	                  minutes:date.minutes,
	                  seconds:date.seconds
	      	    };
	      }
	    });
	    
	 var endTime =  laydate.render({
  	        elem: '#endTime',
  	        done: function(value, date){
  	        	startTime.config.max={
  	    	    		year:date.year,
  	        	    	month:date.month-1,//关键
  	                    date:date.date,
  	                    hours:date.hours,
  	                    minutes:date.minutes,
  	                    seconds:date.seconds
  	    	    }
  	        }
  	    });
		 
	});

layui.use('table', function(){
  var table = layui.table;
 
  //表单重载
  var $ = layui.$, active = {
		    reload: function(){
		    	 var supplierId = $('#supplierId');
		    	 var auditingStatus = $('#auditingStatus');
		      //执行重载    查询
		      table.reload('generalManagerAuditing', {
		        page: {
		          curr: 1 //重新从第 1 页开始
		        }
		        ,where: {
		        	supplierId: supplierId.val(),
		        	auditingStatus: auditingStatus.val()
		        }
		      });
		    }
		  };
  
  
//监听工具条
  table.on('tool(demo)', function(obj){
    var da = obj.data;
    //审核页面
    if(obj.event === 'audit'){
    	layer.open({
    	  title: "生产计划审核",
  		  type: 2, //设置为iframe
  		  area: ['40%', '57%'],
  		  content: ['addAuditing.html?prodId='+da.prodId+"&man=2", 'no'] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
  	  }); 
    //查看详情
    } else if(obj.event === 'productionDetail'){
    	layer.open({
   		 title: "生产计划明细",
   		  type: 2, //设置为iframe
   		  area: ['100%', '400px'],
   		  content: ['../production/productionDetail.html?prodId='+da.prodId] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
   	  }); 
    }else if(obj.event === 'auditingDetail'){
    	layer.open({
      		 title: "审核记录",
      		  type: 2, //设置为iframe
      		  area: ['100%', '400px'],
      		  content: ['productionPlanAuditingDetail.html?prodId='+da.prodId] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
      	  }); 
       }
  });
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});


layui.use(['form', 'table'], function(){
	  var form = layui.form
	  var table = layui.table
	  var url="../../listenSupplier/findSupplier.action";
	  var data=null;
	  $.post(url,data,function(mes){
		  $.each(mes.data,function(i,item){
				  $("#supplierId").append("<option value="+item.suId+">"+item.suName+"</option>")
				  load();
		  })
	  },"json")
	  
});

function load(){
	var form = layui.form;
	form.render();
}
